package com.gzs.learn.payment.mapper;

import com.fasterxml.jackson.core.type.TypeReference;
import com.gzs.learn.payment.IntegrationTestBase;
import com.gzs.learn.payment.model.po.Payment;
import com.gzs.learn.payment.util.ResourceParseUtil;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * @author zhisong.guan
 * @date 2022/11/2 11:51
 */
class PaymentMapperTest extends IntegrationTestBase {
    private static final Long PAYMENT_SERIAL_0 = 10240283908L;
    private static final Long PAYMENT_SERIAL_1 = 10240283137L;

    @Test
    void should_save_payment_0_data_success() throws Exception {
        List<Payment> payments = ResourceParseUtil.parseCollection(ResourceParseUtil.BASE_JSON_PATH + "arch_payment_payment_0.json", new TypeReference<List<Payment>>() {
        });
        for (Payment payment : payments) {
            paymentMapper.insert(payment);
        }

        Payment payment = paymentMapper.selectPaymentById(PAYMENT_SERIAL_0);
        assertThat(payment.getAmt()).isEqualTo(100L);
    }

    @Test
    void should_save_payment_1_data_success() throws Exception {
        List<Payment> payments = ResourceParseUtil.parseCollection(ResourceParseUtil.BASE_JSON_PATH + "arch_payment_payment_1.json", new TypeReference<List<Payment>>() {
        });
        for (Payment payment : payments) {
            paymentMapper.insert(payment);
        }

        Payment payment = paymentMapper.selectPaymentById(PAYMENT_SERIAL_1);
        assertThat(payment.getAmt()).isEqualTo(100L);
    }
}
